<?

/**
* Use $_SESSION["GDate"] if you are using custom date
* or just use the system date 
*
* $today_date = $_SESSION["GDate"];
* $today_date = date("d-m-Y");
*
*/
$today_date		  = date("d-m-Y");

$srcDbHdr    = "USERID_HDR";
$srcDbDtl    = "USERID_DTL";
$srcDbHdrLog = "LOG_USERID_HDR";

$UID     = unserialize($_SESSION["serUID"]);
$userId  = $UID->getUID();

$Db = new oracleDb;
$Db->init($_SESSION["ORCLU"], 
          $_SESSION["OPASS"],
          $_SESSION["SID"],
          _NO_COMMENT);

if($Db->connect()){
	
	$tmpBuf = explode(_DEFAULT_SEPARATOR_02,
	                  $_SESSION["jid"]);
	
	/** 
	* Delete the previous entry
	*
	*/
	$CLHandlers->dbEntDelete($Db,
            	             $tmpBuf[_USER_ID],
            	             $tmpBuf[_USER_COMPANY],
            	             $srcDbHdr);
	            
  $CLHandlers->dbEntDelete($Db,
            	             $tmpBuf[_USER_ID],
            	             $tmpBuf[_USER_COMPANY],
            	             $srcDbDtl);
	
  $nAccess = sizeof($_POST["levelMnEnt"]);
  
  for($iRow = 0; $iRow < $nAccess; $iRow++){
    
    if($_POST["statusEnt"][$iRow]  != '' ||
       $_POST["entryEnt"][$iRow]   != '' ||
       $_POST["modifyEnt"][$iRow]  != '' ||
       $_POST["deleteEnt"][$iRow]  != '' ||
       $_POST["viewEnt"][$iRow]    != '' ||
       $_POST["finalizeEnt"][$iRow]!= '' ||
       $_POST["approvedEnt"][$iRow]!= '' ||
       $_POST["journalEnt"][$iRow] != '' ||
       $_POST["programsEnt"][$iRow]!= '' ||
       $_POST["pictEnt"][$iRow]    != ''){
      
      $values = " '".$_POST["usrIdEnt"]."',           ".
                " '".$_POST["usrCompEnt"]."',         ".
                " '".$_POST["levelMnEnt"][$iRow]."',  ".
                " '".$_POST["descpEnt"][$iRow]."',    ".
                "  ".$CLocal->isTrue($_POST["statusEnt"][$iRow])." ,    ".
                "  ".$CLocal->isTrue($_POST["entryEnt"][$iRow])." ,     ".
                "  ".$CLocal->isTrue($_POST["modifyEnt"][$iRow])." ,    ".
                "  ".$CLocal->isTrue($_POST["deleteEnt"][$iRow])." ,    ".
                "  ".$CLocal->isTrue($_POST["viewEnt"][$iRow])." ,      ".
                "  ".$CLocal->isTrue($_POST["finalizeEnt"][$iRow])." ,  ".
                "  ".$CLocal->isTrue($_POST["approvedEnt"][$iRow])." ,  ".
                "  ".$CLocal->isTrue($_POST["journalEnt"][$iRow])." ,   ".
                "  ".$CLocal->isTrue($_POST["programsEnt"][$iRow])." ,  ".
                "  ".$CLocal->isTrue($_POST["pictEnt"][$iRow])."        ";
      
      $CLHandlers->insToDtl($Db,
                            $values,
                            $srcDbDtl);
    }else{
      
      /* Do nothing */
    }
  }  
  
  $values = " '".$_POST["usrIdEnt"]."',   ".
            " '".$_POST["usrNmEnt"]."',   ".
            " '".$_POST["usrPwdEnt"]."',  ".
            " '".$_POST["usrCompEnt"]."', ".
            " '".$_POST["usrPosEnt"]."',  ".
            " '".$_POST["usrDeptEnt"]."', ".
            " '".$_POST["usrStsEnt"]."'   ";
  
  $CLHandlers->insToHdr($Db,
                        $values,
                        $srcDbHdr);
                               
	$Db->commit();
	
	if($Db->getStatus() == true){
	
	  $Misc->usrMsg("Modify Complete");
	}else{
	  
	  $Misc->usrMsg("Modify Process Interupted");
	}
	
	$Db->dc();
	
	/**
	* Pending...
	* I'm not sure if this 
	* reset procedure off
	* causes buggy 
	*
	*	$restore  = 0;
	* $uprun    = 0;
	* $dataup   = 0;
	*
	*/
	//jumpTo(2,"../".$_SESSION["source_caller"]);
	
}else{
	
	$Misc->usrMsg("Db connection failed");
}

?> 